package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class OOSDemo {
    public static void main(String[] args) throws IOException {
        String name="张三";
        int age=18;
        char gender='男';
        String[] otherInfo={"中国","上海","黑"};
        Person person=new Person();
        person.setName("张三");
        person.setAge(18);
        person.setGender("男");
        person.setOtherInfo (new String[]{"中国","上海","黑"});
        System.out.println(person);

        FileOutputStream fos=new FileOutputStream("person.obj");
        ObjectOutputStream oos=new ObjectOutputStream(fos);

        oos.writeObject(person);
        System.out.println("数据已写入");

        oos.close();
    }
}
